<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <base href="<?php echo base_url(); ?>"/>
    <title><?php echo $title; ?></title>
    <link href="style/base.css" rel="stylesheet" type="text/css"/>
    <link href="style/common.css" rel="stylesheet" type="text/css"/>
    <link href="style/houtai.css" rel="stylesheet" type="text/css"/>
    <link href="style/my.css" rel="stylesheet" type="text/css"/>
    <script type="text/javascript" src="js/jquery-1.7.2.min.js"></script>
    <script src="js/organictabs.jquery.js"></script>
    <script type="text/javascript" src="js/Common.js"></script>
    <script type="text/javascript" src="js/Validation.js"></script>
    <script type="text/javascript" src="jscript/WdatePicker.js"></script>
    <script type="text/javascript" src="js/jquery.form.js"></script>
    <script type="text/javascript" src="js/jquery.blockUI.js"></script>
    <!--[if IE 6]>
    <script type="text/javascript" language="javascript" src="js/ie6/DD_belatedPNG_0.0.8a-min.js"></script>
    <script type="text/javascript" language="javascript">
        DD_belatedPNG.fix('.logo img,.footer_logo img');
    </script>
    <![endif]-->
    <script type="text/javascript">
        $(function () {
            $("#txtActivity").bind("blur", function () {
                checkExperience("txtActivity", "tipA")
            });
            $("#txtTraining").bind("blur", function () {
                checkExperience("txtTraining", "tipT")
            });
            $("#txtCompetition").bind("blur", function () {
                checkExperience("txtCompetition", "tipC")
            });
            $("#txtReward").bind("blur", function () {
                checkExperience("txtReward", "tipR")
            });
            loadUserInfo();
            $("#btnNext").bind("click", save);
        });
        function loadUserInfo() {
            $.ajax({
                type: "post",
                url: "index.php/login/getUserInfo",
                dataType: "json",
                success: function (data) {
                    $("#txtActivity").val(data.activitiexperience);
                    $("#txtTraining").val(data.trainingexperience);
                    $("#txtCompetition").val(data.competitionexperience);
                    $("#txtReward").val(data.reward);
                }
            });
        }

        function checkExperience(id, tipid) {
            var v = $("#" + id).val();
            if (IsEmpty(v)) {
                SetError(tipid, "必填项");
                return false;
            }
            var len = v.length;
            if (len <= 0 || len > 1000) {
                SetError(tipid, "最多1000字");
                return false;
            }
            SetOK(tipid);
            return true;
        }
        function save() {
            if (checkExperience("txtActivity", "tipA") == false)
                return;
            if (checkExperience("txtTraining", "tipT") == false)
                return;
            if (checkExperience("txtCompetition", "tipC") == false)
                return;
            if (checkExperience("txtReward", "tipR") == false)
                return;


            var activity = $("#txtActivity").val();
            var training = $("#txtTraining").val();
            var competition = $("#txtCompetition").val();
            var reward = $("#txtReward").val();

            var params = {
                activity: activity,
                training: training,
                competition: competition,
                reward: reward
            };
            var url = "index.php/login/saveExperience";
            $.ajax({
                type: "post",
                url: url,
                dataType: "json",
                data: params,
                success: function (data) {
                    if (data.ReturnCode == 1) {
                        if ($("#btnNext").attr("src") == "images/bc_inp.jpg") {
                            alert('保存成功');
                            window.location = "<?php echo base_url()?>index.php/manage/experience";
                        }
                        else {
                            window.location = "<?php echo base_url()?>index.php/login/card";
                        }
                    } else {
                        alert('保存失败');
                    }
                }
            });
        }
    </script>
</head>

<body>
<!-- head S-->
<?php
include 'header.php';
?>
<!-- head E-->

<div class="houtai_content mt_10 clearfix">
    <!-- 侧栏 开始 -->
    <?php
    include 'member_left.php';
    ?>
    <!-- 侧栏 结束 -->
    <!-- 用户中心活动经历 S -->
    <div class="houtai_main">
        <div class="houtai_huodong">
            <div class="houtai_main_tit">用户中心—模特档案</div>
            <div class="houtai_huodong_inner">
                <form id="formArchive">
                    <div class="houtai_hd">
                        <span>参加活动经历</span>请注明时间、城市、活动名称
                        <br/>
                        <textarea name="" id="txtActivity" cols="" style="width:620px; height:170px;" rows=""></textarea>
                    </div>
                    <div class="houtai_hd">
                        <span>专业培训经历</span>请注明时间、城市、活动名称
                        <br/>
                        <textarea name="" id="txtTraining" cols="" style="width:620px; height:170px;" rows=""></textarea>
                    </div>
                    <div class="houtai_hd">
                        <span>参加比赛经历</span>请注明时间、城市、活动名称
                        <br/>
                        <textarea name="" id="txtCompetition" cols="" style="width:620px; height:170px;" rows=""></textarea>
                    </div>
                    <div class="houtai_hd">
                        <span>获奖殊荣</span>请注明时间、城市、活动名称
                        <br/>
                        <textarea name="" id="txtReward" cols="" style="width:620px; height:170px;" rows=""></textarea>
                    </div>

                    <div class="houtai_hd_inp">
                        <img id='btnNext' class='link' src='images/bc_inp.jpg'>
                    </div>
                </form>
            </div>
        </div>
    </div>
    <!-- 用户中心活动经历 E -->
</div>
<!-- 底部 S -->
<?php include 'footer.php'; ?>
<!-- 底部 E -->
</body>
</html>
